<div class="pages">
#if($pages)
 #foreach ($p in $pages)
	#if($p.curr)
		<span class="page_2">$p.label</span>
		#set($currp=$p)
	#else
		<a class="page_1" href="$query.copy().set('s', $p.s).set('n', $p.n)">$p.label</a>
	#end
 #end
#end 

 <label class='nospace'>$lang.get('default.list.number')<input type='text' name='_goto_page_count' value= #if($currp) "$currp.n" #else "20" #end/>$lang.get('label.items.and')</label>
 <label class='nospace'><input type='text' name='_goto_page_num' value= #if($currp)'$currp.label' #else '1' #end/>$lang.get('label.page')<a class='page_1' href='javascript:;' onclick='_goto_page()'>$lang.get('a.ok')</a></label>
 #if($total),<label>$lang.get('label.total.item')<i>$total</i>$lang.get('label.items')#if($totalpage)/<i>$totalpage</i>$lang.get('label.pages') #end</label>#end
</div>

<script>
	$(function(){
		var prev = false;
		var next = false;
		var pages = $('.pages');
		if(pages.length == 1) {
			var a = pages.find('a.page_1');
			a.each(function(i, e){
				e = $(e);
				if(e.text().trim() == '<') {
					//prev
					prev = e;
				} else if(e.text().trim() == '>') {
					//next
					next = e;
				}
			});
			if(prev || next) {
				$('body').bind('keydown', function(e){
					var target = e.target.nodeName;
					var edit = (target == 'INPUT' || target == 'SELECT' || target == 'TEXTAREA');
					
					if((!edit) && next && e.which == 39) {
						//right
						next.click();
						e.preventDefault();
					} else if((!edit) && prev && e.which == 37) {
						//left
						prev.click();
						e.preventDefault();
					}
				});
			}
			pages.find('input').bind('keydown', function(e) {
				if(e.which == 13) {
					//enter
					_goto_page();
				}
			});
		}
	});

	function _goto_page() {
		var s = parseInt($('.pages input[name=_goto_page_num]').val());
		var n = parseInt($('.pages input[name=_goto_page_count]').val());
		if (typeof (load) == 'function') {
			load('$query.copy().remove("s", "n").toString()&s=' + ((s - 1) * n)
					+ '&n=' + n);
		} else {
			window.location.href = '$query.copy().remove("s", "n").toString()&s='
					+ ((s - 1) * n) + '&n=' + n;
		}
	}
</script>
 